import React, { Component } from "react";

class Rewtwo extends Component {
  showdata = () => {
    console.log(this);
    let value = this.username.value;
    this.div.innerText = value;
  };
  render() {
    return (
      <>
        <h1>回调函数形式的 raf</h1>
        <input ref={(el) => (this.username = el)} type="text" />
        <button onClick={this.showdata}>显示数据</button>
        <div
          style={{
            width: "300px",
            height: "300px",
            border: "1px solid pink",
            wordBreak: "break-all",
          }}
          ref={(el) => (this.div = el)}
        ></div>
      </>
    );
  }
}

export default Rewtwo;
